package com.easylinkin.sm.controller;

import com.easylinkin.sm.constant.LogConstant;
import com.easylinkin.sm.entity.SystemInfo;
import com.easylinkin.sm.service.SystemInfoService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import site.morn.boot.data.CrudControllerSupport;
import site.morn.log.OperateGroup;
import site.morn.rest.RestBuilders;
import site.morn.rest.RestMessage;
import site.morn.rest.RestModel;
import site.morn.validate.group.Search;

/**
 * 系统信息管理
 *
 * @author wujie
 * @since 1.0.0, 2019/8/19
 */
@Api(tags = "系统信息管理")
@OperateGroup(value = "/systemInfo", args = LogConstant.Module.SYSTEMINFO)
@RestController
@RequestMapping("/systemInfo")
public class SystemInfoController extends
    CrudControllerSupport<SystemInfo, Long, SystemInfoService> {

  @ApiOperation("查询所有")
  @PostMapping({"searchAll"})
  public RestMessage searchAll(
      @Validated({Search.class}) @RequestBody RestModel<SystemInfo> restModel) {
    List<SystemInfo> systemInfos = this.service().searchAll(restModel);
    return RestBuilders.successMessage(systemInfos);
  }

  @ApiOperation("根据城市获取天气")
  @GetMapping("/getWeather")
  public RestMessage getWeather(String city){

//    return RestBuilders.successMessage(WeatherUtils.getWeather(city));
    return RestBuilders.successMessage();
  }

}
